using System.Text.Json.Serialization;

namespace RestaurantFinder.Core.Models;

/// <summary>
/// 餐厅发现页面状态模型 - 用于状态驻留
/// </summary>
public class RestaurantDiscoveryState
{
    /// <summary>
    /// 当前用户位置
    /// </summary>
    public Location? CurrentLocation { get; set; }

    /// <summary>
    /// 搜索到的餐厅列表
    /// </summary>
    public List<Restaurant> Restaurants { get; set; } = new();

    /// <summary>
    /// 选中的推荐餐厅
    /// </summary>
    public Restaurant? SelectedRestaurant { get; set; }

    /// <summary>
    /// 搜索半径（米）
    /// </summary>
    public int SearchRadius { get; set; } = 2000;

    /// <summary>
    /// 选择的餐厅类别
    /// </summary>
    public string SelectedCategory { get; set; } = "餐饮服务";

    /// <summary>
    /// 状态保存时间
    /// </summary>
    public DateTime SavedAt { get; set; } = DateTime.Now;

    /// <summary>
    /// 是否有搜索结果
    /// </summary>
    [JsonIgnore]
    public bool HasResults => Restaurants.Any();

    /// <summary>
    /// 是否有选中的餐厅
    /// </summary>
    [JsonIgnore]
    public bool HasSelectedRestaurant => SelectedRestaurant != null;

    /// <summary>
    /// 状态是否有效（2小时内的状态认为有效）
    /// </summary>
    [JsonIgnore]
    public bool IsValid => DateTime.Now - SavedAt < TimeSpan.FromHours(2);
} 